package cn.tedu.m3;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Scanner;

@Component
public class Producer {
    @Autowired
    private AmqpTemplate t;

    //生成者的发送方法，需要手动调用
    public void send(){
        while (true){
            System.out.println("输入消息： ");
            String s=new Scanner(System.in).nextLine();
            // 指定向 logs 交换机发送, 不指定队列名或路由键
            t.convertAndSend("logs","",s);


        }

    }
}
